fix(codeql): resolve and triage CodeQL findings#209
Conversation
- FileLoaderUtility: copy input stream directly instead of wrapping in an unclosed BufferedInputStream (java/input-resource-leak) - TestDataGenerator: use long loop counter to avoid int/long comparison (java/comparison-with-wider-type) - CollectionLiteralsTest: use String.isEmpty() instead of comparing to "" (java/inefficient-empty-string-test) - FileSystemLoaderTest: create temp file via Files.createTempFile with secure default permissions (java/local-temp-file...-information-disclosure) Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR makes small, unrelated edits: removing BufferedInputStream wrapping in FileLoaderUtility's temp file copy, updating a test filter predicate in CollectionLiteralsTest, switching FileSystemLoaderTest to use JUnit's ChangesMiscellaneous small fixes
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request simplifies stream copying in FileLoaderUtility by removing redundant BufferedInputStream wrapping, improves string emptiness checks in CollectionLiteralsTest, updates temporary file creation in FileSystemLoaderTest to use Files.createTempFile, and fixes a potential type mismatch in TestDataGenerator by changing the loop variable type to long. The reviewer suggested using JUnit 5's @tempdir annotation in FileSystemLoaderTest to manage temporary file lifecycles more robustly instead of relying on deleteOnExit().
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| File tempFile = Files.createTempFile("test", ".txt").toFile(); | ||
| tempFile.deleteOnExit(); |
There was a problem hiding this comment.
Instead of manually creating a temporary file and registering it with deleteOnExit(), which can lead to resource leaks if the JVM crashes or memory accumulation in large test suites, prefer using JUnit 5's @TempDir annotation. This allows JUnit to automatically manage the lifecycle and cleanup of the temporary directory and its contents.
Example:
@Test
void shouldHandleOutputStreamForWritableFile(@org.junit.jupiter.api.io.TempDir java.nio.file.Path tempDir) throws Exception {
File tempFile = tempDir.resolve("test.txt").toFile();
// ...
}Address PR review: replace manual createTempFile + deleteOnExit with a JUnit-managed @tempdir so the temp file lifecycle is handled automatically. Co-Authored-By: Claude <noreply@anthropic.com>
|
Applied in d25b9b0 — replaced the manual |
Summary
Addresses the open CodeQL findings for the repository. Structural Scorecard alerts (Branch-Protection, SAST, Fuzzing, etc.) are out of scope and left untouched.
Fixed in code (4)
java/input-resource-leakFileLoaderUtilityBufferedInputStreamjava/comparison-with-wider-typeTestDataGeneratorlongloop counter to match thelongboundjava/inefficient-empty-string-testCollectionLiteralsTestString.isEmpty()instead of comparing to""java/local-temp-file...-information-disclosureFileSystemLoaderTestFiles.createTempFile(secure default permissions)Dismissed via API (53)
java/missing-override-annotationandjava/unknown-javadoc-parameterare reported against@Getter/@ToString/@EqualsAndHashCode-generated methods;@Overridecannot be added to generated code and the class-level@param <T>javadoc is correct.Proxy*/Null*streams, bean fixtures), tests of deprecated API, and null-argument precondition tests (java/unused-parameter,java/deprecated-call,java/uncaught-number-format-exception,java/dereferenced-expr-may-be-null).java/confusing-method-signatureon intentional public-API overloads that cannot be renamed without breaking the Maven Central API, andjava/missing-clone-methodonPartialArrayListwhich inheritsCloneabletransitively fromArrayListand is not designed for cloning.Verification
./mvnw -Ppre-commit clean verify— BUILD SUCCESS, 887 tests pass, clean tree.Summary by CodeRabbit
Bug Fixes
Tests